home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Environments
/
PowerMacOberon feb96
/
Source
/
Types.Mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1994-11-25
|
2KB
|
67 lines
Syntax10.Scn.Fnt
Syntax12.Scn.Fnt
StampElems
Alloc
25 Nov 94
MODULE Types; (* MB 11.10.91 *) (*<<<< mah
(* Power Macintosh *)
IMPORT Modules, Kernel, S := SYSTEM;
TYPE
Tag = POINTER TO TypeDesc;
Type* = POINTER TO TypeDesc;
TypeDesc* = RECORD
tdsize: LONGINT;
sentinel: LONGINT; (* -4 *)
tag: Tag;
ext0: RECORD
filler: ARRAY 3 OF CHAR;
extlev: SHORTINT
END ;
name*: ARRAY 32 OF CHAR;
module*: Modules.Module
END ;
PROCEDURE This*(mod: Modules.Module; name: ARRAY OF CHAR): Type;
VAR type: Type; tag, i: LONGINT;
BEGIN
IF name # "" THEN
i := mod^.noftds;
WHILE i > 0 DO DEC (i); tag := mod^.typedescs+4*i;
S.GET (tag, tag);
S.GET(tag-4, type);
DEC(S.VAL(LONGINT, type), 2); (* is marked as type desc *)
IF type.name = name THEN RETURN type END;
END
END;
RETURN NIL
END This;
PROCEDURE BaseOf*(t: Type; level: INTEGER): Type;
BEGIN
S.GET(S.VAL(LONGINT, t.tag) - 8 - 4*level, t);
IF t # NIL THEN
S.GET(S.VAL(LONGINT, t) - 4, t);
DEC(S.VAL(LONGINT, t), 2) (* is marked as type desc *)
END ;
RETURN t
END BaseOf;
PROCEDURE LevelOf*(t: Type): INTEGER;
BEGIN
RETURN LONG(t.ext0.extlev)
END LevelOf;
PROCEDURE TypeOf*(o: S.PTR): Type;
VAR type: Type;
BEGIN
S.GET(S.VAL(LONGINT, o)-4, type);
S.GET(S.VAL(LONGINT, type)-4, type);
DEC(S.VAL(LONGINT, type), 2); (* is marked as type desc *)
RETURN type
END TypeOf;
PROCEDURE NewObj*(VAR o: S.PTR; t: Type);
VAR otype: Type;
BEGIN
S.GET(S.VAL(LONGINT, o) - 4, otype);
DEC(S.VAL(LONGINT, otype), 2); (* is marked as type desc *)
IF BaseOf(t, LevelOf(otype)) # otype THEN o := NIL; RETURN END ;
o := S.VAL(S.PTR, Modules.NewRec (S.VAL (LONGINT, t.tag)))
END NewObj;
END Types.